import tkinter as tk
if __name__ == "__main__":
    # 创建主窗口，并设置窗口大小
    root = tk.Tk()
    root.geometry("1000x600")  # 可根据需要调整大小
    up_frame = tk.Frame(root, width=300, height=100, bd=2 )
    up_frame.pack()
    bt_frame = tk.Frame(up_frame, width=300, height=100, bd=2)
    # bt_frame.grid(row=0,column=0)
    bt_frame.pack()
    down_frame = tk.Frame(root, width=300, height=500, bd=2)
    down_frame.pack()
    # 创建输入框上面的文本标签，内容为：待听写内容
    label_title = tk.Label(down_frame, text="待听写内容:",font=("宋体", 12))
    # label_title.pack(side=tk.TOP)
    label_title.grid(row=1,column=0,sticky='w')
    label_title2 = tk.Label(down_frame, text="听写结果:",font=("宋体", 12))
    # label_title.pack(side=tk.TOP)
    label_title2.grid(row=1,column=1,sticky='w')

    # 创建输入框
    textbox = tk.Text(down_frame, wrap=tk.WORD, height=25,width=40,font=("宋体", 16))  # 设置为多行文本框，并允许自动换行
    # textbox.pack(side=tk.LEFT)
    textbox.grid(row=2,column=0)

    # 创建输入框下面的文本标签，用于显示 text_to_speech 函数的返回结果
    textbox2= tk.Text(down_frame, wrap=tk.WORD, height=25,width=40,font=("宋体", 16))  # 设置为多行文本框，并允许自动换行
    # textbox2.pack(side=tk.RIGHT)
    textbox2.grid(row=2,column=1)
    # 按钮用于触发文本转语音功能
    button = tk.Button(bt_frame, text="开始听写", command=lambda: process_entry(textbox.get("1.0", tk.END)),font=("宋体", 12))
    button.pack(side=tk.LEFT)
    # button.grid(row=0,column=1,sticky='e')
    button_stop = tk.Button(bt_frame, text="停止", command=lambda: stop_playing(),font=("宋体", 12))
    # button_stop.grid(row=0,column=1,sticky='e',)
    button_stop.pack(side=tk.RIGHT)
    def stop_playing():
        global Status
        Status = 0
    def set_text(tb,text):
        tb.delete("1.0", tk.END)
        tb.insert("1.0",text)
    def process_entry(text):
        global  Status
        Status = 1

    # 主事件循环
    root.mainloop()